package com.webamc.dao.db4o;

import com.webamc.dao.ICustomerDao;
import com.webamc.model.Customer;
import com.webamc.util.DB4OUtil;
import org.apache.log4j.Logger;

import java.util.List;

/**
 * Date: Mar 9, 2009
 * Time: 12:16:45 AM
 */
public class CustomerDao implements ICustomerDao {
    private Logger log = Logger.getLogger(CustomerDao.class);

    public boolean create(Customer c) {
        return DB4OUtil.insert(c);
    }

    public boolean update(Customer c) {
        return DB4OUtil.update(c);
    }

    public Customer view(int customerId) {
        Customer proto = new Customer();
        proto.setCustomerId(customerId);
        List<Customer> l = search(proto);
        return l.size() > 0 ? l.get(0) : null;
    }

    public List<Customer> search(Customer dummy) {
        return DB4OUtil.select(dummy);
    }

    public List<Customer> browse() {
        return DB4OUtil.getAll(Customer.class);
    }
}
